﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FOBVT.Web.Admin
{
	public partial class AdminLogin : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (IsPostBack)
			{
				string userName = Request.Form["txtUserName"];
				string password = Request.Form["txtPassword"];

				System.Data.OleDb.OleDbConnection Conn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("..\\DB\\FOBVTweb.mdb"));

				MainClass.GetUserInfo userInfoClass = new MainClass.GetUserInfo();
				userInfoClass.Conn = Conn;
				userInfoClass.Email = userName.Trim();
				userInfoClass.Password = FOBVT.Web.MainClass.DEncrypt.Encrypt(password.Trim());

				FOBVT.Web.MainClass.User result = userInfoClass.AdminLogin();

				if (result != null)
				{
					FOBVT.Web.MainClass.SessionState.CurrentUser = result;
					Response.Redirect("Index.aspx");
				}
				else
				{
					FOBVT.Web.MainClass.WebMessageBox.Show(this, "Logon failed！");
				}
			}
		}
	}
}